/**
 * title: useRef
 */
import { useState, Component } from 'react';
import { useMemo, useRef } from 'react';

function App() {
  const [count, setCount] = useState(0);
  const a1 = useRef(1);
  console.log(a1.current); //取子组件实例
  const click = useMemo(() => {
    return () => {
      setCount(count => count + 1);
    };
  }, []);
  return (
    <div>
      <button onClick={click}>点击</button>
      <br />
      <A1 ref={a1} count={count} />
    </div>
  );
}
//类组件
class A1 extends Component {
  click() {
    console.log(1);
  }
  render() {
    return <div>{this.props.count}</div>;
  }
}

export default App;
